<{extend name="public/base"}>
<{block name="head_source"}>
<style type="text/css">
    .navigation-intend td:nth-child(1){
        padding-left:20px;
    }
</style>
<{/block}>
<{block name="content"}>

<div class="box">
    <div class="box-header">
        <h3 class="box-title"><{$title}></h3>
    </div>
    <!-- /.box-header -->
    <div class="box-body">

        <div class="row">
            <div class="col-sm-6">
                <a class="btn  btn-primary" href="javascript:;" id="add-relation">
                    新增
                </a>
            </div>
            <div class="col-sm-6">
                <div id="example1_filter" class="dataTables_filter pull-right">
                    <label>搜索:<input type="search" class="form-control input-sm" placeholder="" aria-controls="example1"></label>
                </div>
            </div>
        </div>

        <table id="example1" class="table table-bordered table-striped">
            <thead>
            <tr>
                <{foreach name="column" id="item" key="k"}>
                <th><{$item.name}></th>
                <{/foreach}>
                <th>操作</th>
            </tr>
            </thead>
            <tbody>
            <{volist name="model" id="item"}>
            <tr>
                <{foreach name="column" id="i" key="k"}>
                <td><?php echo  $parser->{$column[$k]['fun']}($item[$k],$column[$k]['options']); ?></td>
                <{/foreach}>
                <td>
                    <a href="<{:url('admin/enroll/show',array('id'=>$item['id']))}>" class="btn btn-primary btn-sm">查看</a>
                    <a href="javascript:;" data-id="<{$item.user_id}>" class="btn btn-danger btn-sm remove">移除</a>
                </td>
            </tr>
            <{/volist}>

            </tbody>
            <tfoot>
            <tr>
                <{foreach name="column" id="item" key="k"}>
                <th><{$item.name}></th>
                <{/foreach}>
                <th>操作</th>
            </tr>
            </tfoot>
        </table>
        <div></div>

    </div>
    <!-- /.box-body -->
</div>







<!-- 弹出框 -->
<div class="modal fade" id="NoPermissionModal">
    <div class="modal-dialog" style="width: auto;" >
        <div class="modal-content" style="width: 60%;margin:0 auto;">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
                <h4 class="modal-title" id="NoPermissionModalLabel">用户列表</h4>
            </div>
            <div class="modal-body">
                <iframe id="NoPermissioniframe" width="100%" height="500px" frameborder="0"></iframe>
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-default " data-dismiss="modal">    关  闭    </button>
            </div>
        </div>
    </div>
</div>


<div class="modal fade" id="feedback" style="margin-top:300px;">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
            </div>
            <div class="modal-body">
                操作成功 不用不用 麻烦
            </div>
            <div class="modal-footer">

            </div>
        </div>
    </div>
</div>


<{/block}>
<{block name="foot_script"}>


<script>
    $(function(){
        $("#add-relation").click(function(){
            var frameSrc = '<?php echo url("admin/enroll/users"); ?>';
            $("#NoPermissioniframe").attr("src", frameSrc);
            $('#NoPermissionModal').modal({ show: true, backdrop: 'static' });
        });

        $('#NoPermissionModal').on('hidden.bs.modal', function () {
            window.location.reload();
        });
    });



    function makeRelation(user_id){
        $.post('<?php echo url("admin/enroll/makeRelation"); ?>?user_id='+user_id+"&p_user_id=<?php echo $p_user_id; ?>",function(res){
            //在dom中添加节点
            alert(res.msg);

        });
    }

    $(".remove").click(function(){
        var user_id = $(this).data('id');
        $.post('<?php echo url("admin/enroll/removeRelation"); ?>?user_id='+user_id+"&p_user_id=<?php echo $p_user_id; ?>",function(res){
            alert(res.msg);
            window.location.reload();
        });
    });


</script>
<{/block}>

















